@extends('admin.layout')
@section('content')

<!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                电影管理
                <small>修改</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>后台主页</a></li>
                <li><a href="#">电影</a></li>
                <li class="active">修改</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- left column -->
                <div class="col-md-12">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title"> 快速修改电影</h3>
                        </div><!-- /.box-header -->
                        <!-- form start -->
                        <form role="form" action="{{ url('/admin/cate/update') }}" method="post" enctype="multipart/form-data">
                            {{ csrf_field() }}
                            <div class="box-body">
                            @if(count($errors) > 0)
                                <div class="alert alert-danger alert-dismissable">
                                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                    <h4><i class="icon fa fa-ban"></i>警告</h4>
                                    @foreach($errors->all() as $error)
                                            <li>{{$error}}</li>
                                    @endforeach
                                </div>
                            @endif
                            <input type="hidden" name="id" value="{{ $data -> id }}">
                                <div class="form-group">
                                    <label for="exampleInputname">选择类型</label><br />
                                    电影:<input type="radio" name="type" value="0" 
                                    @if($data -> type == 0)
                                        checked
                                    @endif
                                    >
                                    电视:<input type="radio" name="type" value="1" 
                                    @if($data -> type == 1)
                                        checked
                                    @endif>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputname">电影名称</label>
                                    <input type="text" name="name" value="{{ $data -> name }}" class="form-control" id="exampleInputUsername"
                                           placeholder="请输入电影名称">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputname">电影时长</label>
                                    <input type="text" name="timelong" value="{{ $data -> timelong }}" class="form-control" id="exampleInputUsername"
                                           placeholder="如：100分钟">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputname">电影年代</label>
                                    <input type="text" name="time" value="{{ $data -> time }}" class="form-control" id="exampleInputUsername"
                                           placeholder="请输入电影年代  如：2016">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputname">导演</label>
                                    <input type="text" name="director" value="{{ $data -> director }}" class="form-control" id="exampleInputUsername"
                                           placeholder="如：沈严">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputname">编剧</label>
                                    <input type="text" name="scriptwriter" value="{{ $data -> scriptwriter }}" class="form-control" id="exampleInputUsername"
                                           placeholder="如：沈严,陈建斌">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputname">主演</label>
                                    <input type="text" name="cast" value="{{ $data -> cast }}" class="form-control" id="exampleInputUsername"
                                           placeholder="如：演员们,英文名,角色名|演员们,英文名,角色名|演员们,英文名,角色名">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputname">发行公司</label>
                                    <input type="text" name="publish" value="{{ $data -> publish }}" class="form-control" id="exampleInputUsername"
                                           placeholder="如：霍尔果斯春秋时代文化传媒有限公司">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputname">地区</label>
                                    <select class="form-control" name="path">
                                        <option value="中国" 
                                        @if($data -> path == '中国')
                                            selected ="selected"
                                        @endif
                                        >中国</option>
                                        <option value="港台" 
                                        @if($data -> path == '港台')
                                            selected ="selected"
                                        @endif>港台</option>
                                        <option value="美国" 
                                        @if($data -> path == '美国')
                                            selected ="selected"
                                        @endif>美国</option>
                                        <option value="韩国" 
                                        @if($data -> path == '韩国')
                                            selected ="selected"
                                        @endif>韩国</option>
                                        <option value="泰国" 
                                        @if($data -> path == '泰国')
                                            selected ="selected"
                                        @endif>泰国</option>
                                        <option value="欧洲" 
                                        @if($data -> path == '欧洲')
                                            selected ="selected"
                                        @endif>欧洲</option>
                                        <option value="印度" 
                                        @if($data -> path == '印度')
                                            selected ="selected"
                                        @endif>印度</option>
                                        <option value="新加坡" 
                                        @if($data -> path == '新加坡')
                                            selected ="selected"
                                        @endif>新加坡</option>
                                        <option value="加拿大" 
                                        @if($data -> path == '加拿大')
                                            selected ="selected"
                                        @endif>加拿大</option>
                                        <option value="澳大利亚" 
                                        @if($data -> path == '澳大利亚')
                                            selected ="selected"
                                        @endif>澳大利亚</option>
                                        <option value="其他" 
                                        @if($data -> path == '其他')
                                            selected ="selected"
                                        @endif>其他</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputname">电影类型</label>
                                    <div class="form-group">
                                        <div class="checkbox">
                                            <style type="text/css">
                                                .che
                                                {
                                                    margin-right: 20px;
                                                }
                                            </style>
                                            <label class="che" style="margin-left: 10px;">
                                                <input type="checkbox" name="pid[]" value="动作" 
                                                    @if(in_array('动作', $data -> pid))
                                                        checked
                                                    @endif>
                                                动作
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="爱情" 
                                                    @if(in_array('爱情', $data -> pid))
                                                        checked
                                                    @endif>
                                                爱情
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="喜剧" 
                                                    @if(in_array('喜剧', $data -> pid))
                                                        checked
                                                    @endif>
                                                喜剧
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="恐怖" 
                                                    @if(in_array('恐怖', $data -> pid))
                                                        checked
                                                    @endif>
                                                恐怖
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="科幻" 
                                                    @if(in_array('科幻', $data -> pid))
                                                        checked
                                                    @endif>
                                                科幻
                                            </label class="che">
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="悬疑" 
                                                    @if(in_array('悬疑', $data -> pid))
                                                        checked
                                                    @endif>
                                                悬疑
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="惊悚" 
                                                    @if(in_array('惊悚', $data -> pid))
                                                        checked
                                                    @endif>
                                                惊悚
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="战争" 
                                                    @if(in_array('战争', $data -> pid))
                                                        checked
                                                    @endif>
                                                战争
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="武侠" 
                                                    @if(in_array('武侠', $data -> pid))
                                                        checked
                                                    @endif>
                                                武侠
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="文艺" 
                                                    @if(in_array('文艺', $data -> pid))
                                                        checked
                                                    @endif>
                                                文艺
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="犯罪" 
                                                    @if(in_array('犯罪', $data -> pid))
                                                        checked
                                                    @endif>
                                                犯罪
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="灾难" 
                                                    @if(in_array('灾难', $data -> pid))
                                                        checked
                                                    @endif>
                                                灾难
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="动画" 
                                                    @if(in_array('动画', $data -> pid))
                                                        checked
                                                    @endif>
                                                动画
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="奇幻" 
                                                    @if(in_array('奇幻', $data -> pid))
                                                        checked
                                                    @endif>
                                                奇幻
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="冒险" 
                                                    @if(in_array('冒险', $data -> pid))
                                                        checked
                                                    @endif>
                                                冒险
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="剧情" 
                                                    @if(in_array('剧情', $data -> pid))
                                                        checked
                                                    @endif>
                                                剧情
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="家庭" 
                                                    @if(in_array('家庭', $data -> pid))
                                                        checked
                                                    @endif>
                                                家庭
                                            </label>
                                            <label class="che">
                                                <input type="checkbox" name="pid[]" value="其他" 
                                                    @if(in_array('其他', $data -> pid))
                                                        checked
                                                    @endif>
                                                其他
                                            </label>

                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputFile">海报</label>
                                    <input id="exampleInputFile" type="file" name="photo">
                                    <p class="help-block">如果不上传，默认还是上次修改的海报</p>
                                </div>
                                <div>
                                    <h4 class="box-title">剧情简介
                                        <!-- <small>发行公司、导演编剧及主演</small> -->
                                    </h4>
                                    <div class="box-body pad">
                                            <textarea style="width: 100%; height: 151px; resize: none;" id="editor1" name="synopsis" rows="10" cols="80" placeholder="剧情简介">{{ $data -> synopsis }}</textarea>
                                    </div>
                                </div>
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">修改</button>
                            </div>
                        </form>
                    </div><!-- /.box -->
                </div><!--/.col (left) -->     
            </div>   <!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
<script type="text/javascript">
    $('input[name="time"]').on('blur', function(){
        //获取输入的值
        var v = this.value;
        // console.log(v);
        //声明正则
        var reg = /^\d{4}$/;
        //验证
        var res = reg.test(v);
        //判断
        if(res)
        {
            this.style.border = '1px solid #0f0';
        }else {
            this.style.border = '2px solid #f00';
        }
    })
</script>
@endsection